<template>
  <div class="page-login-v3">
    <div class="container">
      <div id="wrapper" class="login-body">
        <div class="login-content">
          <div class="brand">
            <img
              alt="logo"
              class="brand-img"
              src="../../static/image/logo.png"
            />
            <h2 class="brand-text">渠道运营管理系统</h2>
          </div>
          <form id="login-form" class="login-form">
            <div class="form-group">
              <input
                class=""
                v-model="account"
                placeholder="请输入用户名"
                type="text"
              />
            </div>
            <div class="form-group">
              <input
                class=""
                v-model="password"
                placeholder="请输入密码"
                type="password"
              />
            </div>
            <div class="form-group">
              <button id="btn-submit" type="submit" @click="onLogin()">
                登录
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import "@/static/style/login.scss";

export default {
  name: "login",
  data() {
    return {
      account: "",
      password: "",
      isFocusPwd: false,
      isFocus: false,
      isPwd: true,
      loading: false,
    };
  },
  methods: {
    check() {
      this.isPwd = !this.isPwd;
    },
    onLogin() {
      if (this.account == "") {
        this.$message.warning("请输入账号");
        return;
      }
      if (this.password == "") {
        this.$message.warning("请输入密码");
        return;
      }
      this.loading = true;
      if (this.account == "admin" && this.password == "123123") {
        this.loading = false;
        // sessionStorage.setItem("token", res.data.token);
        // sessionStorage.setItem("name", res.data.name);
        // sessionStorage.setItem("token", res.data.token);
        sessionStorage.setItem("name", this.account);
        this.$router.push({
          name: "home",
        });
      } else {
        this.$message.warning("账号或密码错误");
        return;
      }
    },
  },
};
</script>
